/******************************************************************************
** 
** Detab.
** 
** File name:	tab_replace.c
** Compilation:	cc tab_replace.c -o tab_replace
** Execution:	./tab_replace
** 
** Description:
** Reads the input, replaces every tab with '_' to the end of that tab.
** 
******************************************************************************/
#include <stdio.h>

#define TAB_WIDTH 8
#define REPLACE_SYMBOL '_'

main()
{
    int c, i;
    
    i = 0;
    while ((c = getchar()) != EOF) {
        ++i;
        if (i == TAB_WIDTH) {
            i = 1;
        };
        
        if (c == '\t') {
            for (i; i<= TAB_WIDTH; ++i) {
                printf("%c", REPLACE_SYMBOL);
            }
            i = 0;
        } else if (c == '\n') {
            i = 0;
            printf("\n");
        } else {
            putchar(c);
        }
        
    }
}

